this.name = "rmb-cascade-missile-script";
this.author = "Ramirez";
this.copyright = "December 2008";
this.description = "Checks for mass before successfully detonating a Blue Steel cascade missile.  If mass is present, missile explodes harmlessly";
this.version = "1.0";

this.checkForPlanetProximity = function() 
{ 
   function isAPlanet(entity) 
   { 
      return entity.isPlanet || entity.isSun 
   } 
   var closestPlanet = system.filteredEntities(this, isAPlanet, this.ship)[0] 
   if(closestPlanet == null) this.ship.reactToAIMessage("DETONATE") 
   else if(this.ship.position.distanceTo(closestPlanet) < closestPlanet.radius * 1.33) this.ship.reactToAIMessage("DEFUSE") 
   else this.ship.reactToAIMessage("DETONATE") 
}